<?php
include "../../../lib/list.php";
if($_GET['date'])$date = $_GET['date'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/print.css" type="text/css"></link>
<script language="javascript">
window.onload = function ()
{
	print();
}
</script>
</head>
<body style="padding:10px;margin:10px;">
        <table width="650"  border="0" height="491" cellpadding="0" cellspacing="0">
                                <tr> 
                                    <td valign="top">
                    <h1 class='rpt_title' style='font-size: 20px; height:25px;'>재&nbsp;고&nbsp;조&nbsp;정&nbsp;전&nbsp;표</h1>
             <!-- TopSql 시작 -->
                    <table border="0" cellpadding="0" cellspacing="0" width="650px">
                        <tr>
                           <td style="width:300px">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
						<?
						$qry = "SELECT * FROM uatp_prdgroup WHERE date = '$date'";
						$group = DBarray($qry);
						
						$qry = "SELECT uatp_shopinfo.name AS 'shopname', uatp_prdreview.no,
								uatp_prdreview.count, uatp_prdreview.unit, uatp_prdgroup.date, uatp_prdgroup.note,
								uatp_prdreview.admin_name AS 'name'
								FROM uatp_prdreview
								INNER JOIN uatp_shopinfo ON uatp_prdreview.s_no = uatp_shopinfo.no
								INNER JOIN uatp_prdgroup ON uatp_prdreview.date = uatp_prdgroup.date
								WHERE uatp_prdreview.date='$date' LIMIT 0 , 1";
												$info = DBarray($qry);
						?>
                                        <th style='height:15px'>전표번호</th>
                                        <td><?=date('ymd-his',strtotime($info['date']))?></td>
                                    </tr>
                                    <tr> 
                                        <th style='height:15px'>DATE</th>
                                        <td><?=date('Y/m/d',strtotime($info['date']))?></td>
                                    </tr>
                                </table>
                            </td>
                            <td rowspan="2">&nbsp;</td>
                            <td style="width:340px">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
                                        <th style='height:15px'>점포명</th>
                                        <td><?=$info['shopname']?></td>
                                    </tr>
                                    <tr>
                                        <th style='height:15px'>담당자</th>
                                        <td><?=$info['name']?></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                    
                    <!-- TopSql 끝 -->
        
                    <!-- 구매리스트 시작 -->
                    <table class="p_rptC" width="650" >                    
                            <col width="8%" />                            
                            <col width="" />                            
                            <col width="43%" />
                            <col width="9%" />  
                            <thead>
                        <tr>
                                        <th style="height:23px">순번</th>   
                                        <th style="height:23px">품목</th>   
                                        <th style="height:23px">품명 및 규격 </th>   
                                        <th style="height:23px">수량</th>   
                        </tr>
                           <?php 
                    $bunho = 0;
					$query = "SELECT * FROM uatp_prdreview WHERE date = '$date'";
					$result = DBquery($query);
					while($list = mysql_fetch_array($result)){
						$bunho++;
					$qry = "SELECT * FROM uatp_product WHERE no = $list[p_no]";
					$product = DBarray($qry);
						$total_price += $list['price'];
						$total_count += $list['count'];
					?>
                        <tr height="22px;" >
                        <td style="text-align:center;font-size:11px; width:8%;"><?=$bunho?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:17%;">&nbsp;<?=$product['barcode']?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:43%;">&nbsp;<?=$product['productname']?>&nbsp;</td>
                        <td style="text-align:right;font-size:11px; width:9%;"><?=$list['count']?>&nbsp;</td>
                        </tr>
                    <?php
					} ?>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <!-- 구매리스트 끝 -->
                
                    <!-- 내용 -->
                    <table class="p_rptB">
                        <col width="100px" />
                        <col />
                        <tr>
                            <th style='height:13px'>비고</th>
                            <td class="left"><?=$group['note']?></td>
                        </tr>
                    </table>
                    <!-- 내용 끝 -->
                    
                    <!-- 각페이지통계 시작(수량, 인수) -->
                    <table class="p_rptB">
                        <col width="100px" />
                        <col />
                        <col width="100px" />
                        <col width="150px" />
                        <tr>
                            <th style='height:13px'>수량</th>
                            <td class="right"><?=$total_count?>&nbsp;</td>
                            <th style='height:13px'>인수</th>
                            <td class="right">인</td>
                        </tr>
                    </table>
                    <!-- 각페이지통계 끝 -->
                    <!-- 추가입력사항 시작 -->
                    <table class="p_rptB2"  style="margin:3px 0 0 0;">
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                        
                    </table>            
                   </td>
                   </tr>
                   </table>         
</body>
</html>